<template>
  <Card title="评论审批">
    <Card :bordered="false">
      <Select style="width: 150px"
              v-model="bo.cuCommentsIs">
        <Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option>
      </Select>
      <Button type="primary" @click="query" style="margin-left: 15px">查询</Button>
    </Card>
    <Table border stripe ref="selection" size="small" :columns="columns" :data="nowData">
      <template slot-scope="{ row, index }" slot="action">
        <div style="margin: 10px">
          <Button @click="showOne(row)">查看文章内容</Button>
          <div v-if="row.cuCommentsIs == 0 ">
            <Button type="primary" size="small" style="margin-right: 5px" @click="modal1 = true">审核</Button>
            <Button type="error" size="small" @click="modal2 = true">驳回</Button>
          </div>
        </div>
        <Modal
          v-model="modal1"
          title="提示"
          @on-ok="update(row.cuCommentsId,'1')">
          <p>确定要审核通过吗?</p>
        </Modal>
        <Modal
          v-model="modal2"
          title="提示"
          @on-ok="update(row.cuCommentsId,'2')">
          <p>确定要驳回吗?</p>
        </Modal>
      </template>
    </Table>
    <Page :total="dataCount" :current="bo.current" :page-sizer="bo.size" @on-change="changePage"
          @on-page-size-change="_nowPageSize"
          show-total show-sizer show-elevator/>

    <Modal :fullscreen="true" title="查看内容" v-model="visible" class-name="fl-image-modal"   @on-ok="okEnd">
      <Form  :label-width="80">
        <FormItem label="标题" >
          {{formItem.cuThearTitle}}
        </FormItem>
        <FormItem label="内容" >
          <div v-html="formItem.cuThearCenter">

          </div>
        </FormItem>
      </Form>
    </Modal>

  </Card>
</template>

<script>
export default {
  name: "thear_comments",
  data(){
    return{
      visible:false,
      modal2:false,
      modal1:false,
      updateWebCommentsBO:{
        cuCommentsId:null,
        cuCommentsIs:null,//是否通过审核 0否1是2驳回
      },
      dataCount:0,
      bo:{
        size:10,
        current:1,
        cuCommentsIs:'0',
      },
      nowData:[],
      columns:[
        {
          title: '序号',
          key: 'cuCommentsId'
        },
        {
          title: '评论内容',
          key: 'cuCommentsCenter'
        },
        {
          title: '评论时间',
          key: 'cuCommentsCreateDate'
        },
        {
          title: '评论用户',
          key: 'cuExt2'
        },
        {
          title: '操作',
          slot: 'action',
          width: 150,
          align: 'center'
        }
      ],
      selectData:'0',
      cityList:[  {
        value: '0',
        label: '未审核'
      }, {
        value: '1',
        label: '已审核'
      }, {
        value: '2',
        label: '已驳回'
      }],
      formItem:{},
    }
  },methods:{
    showOne(row){
      this.visible = true;
      this.$axios_supermall.post('/thear/queryOne', row.cuExt1).then(resp => {
        if (resp.data.code == 0) {
          this.formItem = resp.data.data
        }
        // this.$refs.editor.setHtml(this.formItem.cuThearCenter)
      })
    },
    okEnd(){

    },
    query(){
    this.$axios_supermall.post("/CuWebComments/queryAdminComments",this.bo).then(resp =>{
      if (resp.data.code == 0){
        let data = resp.data.data
        this.nowData = data.records
        this.dataCount = data.total
        this.bo.current = data.current;
        this.bo.size = data.size;
      }
    })
    },
    update(cuCommentsId,cuCommentsIs){
      this.updateWebCommentsBO.cuCommentsId = cuCommentsId;
      this.updateWebCommentsBO.cuCommentsIs = cuCommentsIs;
      this.$Loading.start()
      this.$axios_supermall.post("/CuWebComments/updateAdminComments",this.updateWebCommentsBO).then(resp =>{
        if (resp.data.code == 0){
          this.$Message.success("处理成功");
          this.query();
        }
        this.$Loading.finish()
      }).catch(() => {
        this.$Loading.error()
      })
    },
    changePage(index){
      this.bo.current = index;
      this.query();
    },
    _nowPageSize(index){
      this.bo.size = index
      this.query()
    }

  },mounted() {
    this.query();
  }
}
</script>

<style scoped>

</style>
